#include "utils.hpp"

#include <cctype>

namespace mashine { namespace utils {

bool is_variable_name(std::string const & variable)
{
	BOOST_FOREACH(char ch, variable)
	{
		if (std::islower(ch)) return false;
	}
	
	return true;
}

bool is_constant_name(std::string const & constant)
{
	BOOST_FOREACH(char ch, constant)
	{
		if (std::isupper(ch)) return false;
	}
	
	return true;
}

bool is_Literal_name(std::string const & Literal)
{
	BOOST_FOREACH(char ch, Literal)
	{
		if (std::islower(ch)) return false;
	}
	
	return true;
}

bool is_analogy_name(std::string const & analogy)
{
	BOOST_FOREACH(char ch, analogy)
	{
		if (std::isupper(ch)) return false;
	}
	
	return true;
}

std::string vector_of_map_to_string(std::vector<std::map<std::string, std::string> > const & v)
{
	std::string buff;

	std::vector<std::map<std::string, std::string> >::const_iterator i;
	for (i = v.begin(); i != v.end(); ++i)
	{
		buff.append( "[" );
		std::map<std::string, std::string>::const_iterator ii;
	
		for (ii = (*i).begin(); ii != (*i).end(); ++ii)
		{
			buff.append((*ii).first);
			buff.append(":");
			buff.append((*ii).second);
			buff.append(", ");
		}
		
		if ((*i).size() != 0) 
		{
			buff.erase(buff.size() - 2, 2);
		}
		
		buff.append( "]" );
		buff.append( ", " );
	}
	
	if (v.size() != 0) 
	{
		buff.erase(buff.size() - 2, 2);
    }
	
	return buff;
}

}}